from os import path
#设置文件path变量
url_file = "./list.txt"
#判断文件是否存在
def get_domain_port(url_file):
    if path.exists(url_file):
        #打开文件
        file = open(url_file, "r", encoding='utf-8')
        #遍历文件行内容
        for (num, li) in enumerate(file, 1):
            print(num)
            li = li.replace("\n", "")
            print("正在检测第[ %s ]行内容: [ %s ] " %(num, li))
            # xi = li.split(' ', 2)
            xi2 = [li]
            for i in xi2:
                domain_port = i.split(' ')
                domain = domain_port[0]
                port = domain_port[1]
                print("第[ %s ]行获取的域名：[ %s ] " %(num, domain))
                print("第[ %s ] 行获取的端口：[ %s ] " %(num, port))
                return domain,port
        file.close()
    else:
        exit("找不到文件[%s]" %url_file)
i = get_domain_port(url_file=url_file)
# print(i)